#region

using System;
using System.ComponentModel.DataAnnotations;
using InfoTech.VinhSon.Bussiness;

#endregion

namespace InfoTech.VinhSon.Models
{
    [Serializable]
    public partial class SectionModel
    {
        #region Constructor

        public SectionModel(Section value)
        {
            Id = value.Id;
            if(value.Article != null)
                ArticleId = value.Article.Id;
            Name = value.Name;
            Url = value.Url;
            Height = value.Height;
            Width = value.Width;
            Priority = value.Priority;
            Detail = value.Detail;
            Word = value.Word ?? false;
            Pdf = value.Pdf ?? false;
            PowerPoint = value.PowerPoint ?? false;
            Video = value.Video ?? false;
            Other = value.Other ?? false;
            Activated = value.Activated ?? false;
        }

        #endregion

        #region Fields

        private Boolean _Activated;

        private Int32? _ArticleId;

        private String _Detail;

        private Int32? _Height;

        private Int32 _Id;

        private String _Name;

        private Boolean _Other;

        private Boolean _Pdf;

        private Boolean _PowerPoint;

        private Int32? _Priority;

        private String _Url;

        private Boolean _Video;

        private Int32? _Width;

        private Boolean _Word;

        #endregion

        #region Properties

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Int32 Id
        {
            get
            {
                return _Id;
            }
            set
            {
                _Id = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Int32? ArticleId
        {
            get
            {
                return _ArticleId;
            }
            set
            {
                _ArticleId = value;
            }
        }

        [Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(1000, ErrorMessage = "Value must be under 1000 characters")]
        public String Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(500, ErrorMessage = "Value must be under 500 characters")]
        public String Url
        {
            get
            {
                return _Url;
            }
            set
            {
                _Url = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Int32? Height
        {
            get
            {
                return _Height;
            }
            set
            {
                _Height = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Int32? Width
        {
            get
            {
                return _Width;
            }
            set
            {
                _Width = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Int32? Priority
        {
            get
            {
                return _Priority;
            }
            set
            {
                _Priority = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        [StringLength(1073741823, ErrorMessage = "Value must be under 1073741823 characters")]
        public String Detail
        {
            get
            {
                return _Detail;
            }
            set
            {
                _Detail = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Boolean Word
        {
            get
            {
                return _Word;
            }
            set
            {
                _Word = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Boolean Pdf
        {
            get
            {
                return _Pdf;
            }
            set
            {
                _Pdf = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Boolean PowerPoint
        {
            get
            {
                return _PowerPoint;
            }
            set
            {
                _PowerPoint = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Boolean Video
        {
            get
            {
                return _Video;
            }
            set
            {
                _Video = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Boolean Other
        {
            get
            {
                return _Other;
            }
            set
            {
                _Other = value;
            }
        }

        //[Required]
        //[Range(0, 0, ErrorMessage = "Value must be between 0 and 0")]
        //[StringLength(0)]
        public Boolean Activated
        {
            get
            {
                return _Activated;
            }
            set
            {
                _Activated = value;
            }
        }

        #endregion

        #region Operators

        public void Update(Section value)
        {
            // value.Id = Id;
            value.Name = Name;
            value.Url = Url;
            value.Height = Height;
            value.Width = Width;
            value.Priority = Priority;
            value.Detail = Detail;
            value.Word = Word;
            value.Pdf = Pdf;
            value.PowerPoint = PowerPoint;
            value.Video = Video;
            value.Other = Other;
            value.Activated = Activated;
        }

        public static implicit operator SectionModel(Section obj)
        {
            return new SectionModel(obj);
        }

        public static implicit operator Section(SectionModel obj)
        {
            Section value = new Section();
            obj.Update(value);
            return value;
        }

        #endregion
    }
}
